
<template>
  <el-container>
    <el-header>
      <div style="padding-left: 65%">
        <el-popconfirm
            confirm-button-text='删除'
            cancel-button-text='取消'
            icon="el-icon-info"
            icon-color="red"
            @onConfirm="delete_emp()"
            title="您确定删除该岗位吗？"
        >
          <el-button slot="reference" type="danger" icon="el-icon-delete-solid">删除岗位</el-button>
        </el-popconfirm>
      </div>
    </el-header>
    <div style="width: 80%;padding-left: 10%;margin-top: 20px" >
      <el-container>
        <el-aside  width="80%;">
          <div class="demo-fit" style="margin-top: 20px;text-align: center">
            <div class="block">
              <el-avatar shape="square" :size="100" :src="dz+url"></el-avatar>
            </div>
            <h1 style=" text-align: center;">{{workinfo.enterInfo.principal}}</h1>
            <h4  style=" text-align: center;">{{workinfo.enterInfo.cname}}</h4>
          </div>

          <div class="srca">
            <h3>
              <i class="fa fa-user" aria-hidden="true"></i>基本信息</h3>
            <hr/>
            <ul>
              <li>
                <label>上市情况：</label>
                <span>{{workinfo.enterInfo.listing}}</span>
              </li>
              <li>
                <label>公司人数：</label>
                <span>{{workinfo.enterInfo.people}}</span>
              </li>
            </ul>
          </div>
          <div class="srca">
            <h3>
              <i class="fa fa-phone-square" aria-hidden="true"></i>联系方式</h3>
            <hr/>
            <ul>
              <li>
                <label>手机：</label>
                <span>{{workinfo.enterInfo.tel}}</span>
              </li>
              <li>
                <label>邮箱：</label>
                <span>{{workinfo.enterInfo.email}}</span>
              </li>
            </ul>
          </div>
          <div class="srca">
            <h3>
              <i class="fa fa-gear" aria-hidden="true"></i>公商信息</h3>
            <hr/>
            <ul>
              <li>
                <label>公司名称：</label>
                <span >{{workinfo.enterInfo.cname}}</span>
              </li>
              <li>
                <label>法人代表：</label>
                <span >{{workinfo.enterInfo.legal}}</span>
              </li>
              <li>
                <label>注册资金：</label>
                <span >{{workinfo.enterInfo.money}}</span>
              </li>
              <li>
                <label>成立时间：</label>
                <span >{{workinfo.enterInfo.time}}</span>
              </li>
              <li>
                <label>企业类型：</label>
                <span >{{workinfo.enterInfo.attribute}}</span>
              </li>
              <li>
                <label>经营状态：</label>
                <span >{{workinfo.enterInfo.status}}</span>
              </li>
            </ul>
          </div>
        </el-aside>
        <el-main>
          <div>
            <div>
              <h3>
                <i class="fa fa-laptop" aria-hidden="true"></i>职位描述</h3>
              <hr/>
              <ul>
                <li>
                  <h3>
                    <span>工作职责<el-link icon="el-icon-edit" type="success" style="margin-left: 20px" @click="add('dialog')">编辑</el-link></span>
                  </h3>
                  <p v-html="workinfo.opera"></p>
                </li>
                <li>
                  <h3>
                    <span>任职要求<el-link icon="el-icon-edit" type="success" style="margin-left: 20px" @click="add('lxfs')">编辑</el-link></span>
                  </h3>
                  <p v-html="workinfo.claim"></p>
                </li>
              </ul>
            </div>
            <div class="work info-unit">
              <h3>
                <i class="fa fa-institution" aria-hidden="true"></i>公司介绍<el-link icon="el-icon-edit" type="success" style="margin-left: 20px" @click="add('info')">编辑</el-link></h3>
              <hr/>
              <ul class="info-content">
                <li style="list-style-type:none;">
                  <p v-html="workinfo.enterInfo.info">
                  </p>
                </li>
              </ul>
            </div>
            <div class="work info-unit">
              <h3>
                <i class="fa fa-globe" aria-hidden="true"></i>详细地址：<el-link icon="el-icon-edit" type="success" style="margin-left: 20px" @click="add('address')">编辑</el-link></h3>
              <hr/>
              <div class="location-address">{{workinfo.address.detailaddr}}</div>
              <div class="amap-wrapper">
                <el-amap class="amap-box" :vid="'amap-vue'" :center="[log,loh]" :zoom="zoom"></el-amap>
              </div>
            </div>
          </div>
        </el-main>
      </el-container>
      <el-dialog title="编辑工作职责" :visible.sync="grinfo_state">
        <el-form ref="form" :model="work_from" label-width="80px">
          <vTinymce v-model="work_from.opera" />

          <div align="center">
            <el-button
                type="success"
                size="small"
                @click="add('add')"
                v-show="password_input_state"
            >确认</el-button
            >
          </div>
        </el-form>
      </el-dialog>
      <el-dialog title="编辑公司介绍" :visible.sync="gs_state">
        <el-form ref="form" :model="work_from" label-width="80px">
          <vTinymce v-model="work_from.info" />

          <div align="center">
            <el-button
                type="success"
                size="small"
                @click="add('infoadd')"
                v-show="gs_input_state"
            >确认</el-button
            >
          </div>
        </el-form>
      </el-dialog>
      <el-dialog title="编辑任职要求" :visible.sync="lxfs_state">
        <el-form ref="form" :model="work_from" label-width="80px">
          <vTinymce v-model="work_from.claim" />
          <div align="center">
            <el-button
                type="success"
                size="small"
                @click="add('lxfsadd')"
                v-show="lxfs_input_state"
            >确认</el-button
            >
          </div>
        </el-form>
      </el-dialog>
      <el-dialog title="编辑详细地址" :visible.sync="address_state">
        <el-form ref="form" :model="work_from" label-width="80px">
          <el-form-item label="地址">
            <el-cascader
                style="width: 300px"
                size="large"
                :options="options"
                v-model="selectedOptions"
            >
            </el-cascader>
          </el-form-item>
          <el-form-item label="详细地址">
            <el-input v-model="work_from.xxdz"  style="width: 300px"></el-input>
          </el-form-item>
          <div align="center">
            <el-button
                type="success"
                size="small"
                @click="add('addresadd')"
                v-show="address_input_state"
            >确认</el-button
            >
          </div>
        </el-form>
      </el-dialog>
    </div>
  </el-container>
</template>
<script>
import {CodeToText, regionData} from 'element-china-area-data'
export default {
  name: "EnterInfo",
  data(){
    return {
      options: regionData,
      selectedOptions: [],
      work_from:{
        opera:"",
        tel:"",
        email:"",
        xxdz:"",
        info:"",
      },
      flag : "",
      grinfo_state: false,
      lxfs_state: false,
      address_state: false,
      gzjl_input_state:false,
      gs_state: false,
      gs_input_state:false,
      lxfs_input_state: false,
      address_input_state: false,
      type:this.$route.query.type,
      log: "",
      loh: "",
      dz:this.$axios.defaults.baseURL,
      zoom: 20,//初始化地图显示层级
      mapStyle: "amap://styles/8b6be8ec497009e17a708205348b899a", //设置地图样式
      workinfo: {},
      wid: this.$route.query.wid,
      tid: this.$route.query.tid,
      url: "",
      claim: "",
      opera: "",
      count: 1,
      slotStyle: {
        padding: '2px 8px',
        background: '#eee',
        color: '#333',
        border: '1px solid #aaa'
      },
    }
  },
  methods:{
    add(key) {
      switch (key) {
        case "dialog":
          this.work_from.opera = this.workinfo.opera;
          this.grinfo_state = true;
          this.password_input_state = true;
          break;
        case "add":
          this.$axios({
            url: this.$axios.defaults.baseURL+"/enterprise/updateWork",
            method: "post",
            params:{
              opera:this.work_from.opera,
              tid:this.tid,
              wid:this.wid,
              uid:this.workinfo.enterInfo.uid,
              type:"gzzz"
            }
          }).then(res => {
            if(res.status){
              this.$message.success(res.data.msg);
            }else {
              this.$message.error(res.data.msg);
            }
            setTimeout(() => {
              this.grinfo_state = false;
              this.password_input_state = false;
              this.enterinfo();
            }, 1500);
          })
          break;
        case "lxfs":
          this.work_from.claim = this.workinfo.claim;
          this.lxfs_state = true;
          this.lxfs_input_state = true;
          break;
        case "lxfsadd":
          this.$axios({
            url: this.$axios.defaults.baseURL+"/enterprise/updateWork",
            method: "post",
            params:{
              claim: this.work_from.claim,
              tid:this.tid,
              wid:this.wid,
              uid:this.workinfo.enterInfo.uid,
              type:"rzyq"
            }
          }).then(res => {
            if(res.status){
              this.$message.success(res.data.msg);
            }else {
              this.$message.error(res.data.msg);
            }
            setTimeout(() => {
              this.lxfs_state = false;
              this.lxfs_input_state = false;
              this.enterinfo();
            }, 1500);
          })
          break;
        case "address" :
          this.address_state = true;
          this.address_input_state = true;
          break;
        case "addresadd":
          this.$axios({
            url: this.$axios.defaults.baseURL+"/enterprise/updateaddress",
            method: "post",
            params:{
              location: CodeToText[this.selectedOptions[0]]+CodeToText[this.selectedOptions[1]]+CodeToText[this.selectedOptions[2]],
              tid:this.tid,
              wid:this.wid,
              uid:this.workinfo.enterInfo.uid,
              detailaddr:this.work_from.xxdz,
              province:CodeToText[this.selectedOptions[0]]
            }
          }).then(res => {
            if(res.status){
              this.$message.success(res.data.msg);
            }else {
              this.$message.error(res.data.msg);
            }
            setTimeout(() => {
              this.address_state = false;
              this.address_input_state = false;
              this.enterinfo();
            }, 1500);
          })
          break;
        case "info":
          this.work_from.info = this.workinfo.enterInfo.info;
          this.gs_state = true;
          this.gs_input_state = true;
          break;
        case "infoadd":
          this.$axios({
            url: this.$axios.defaults.baseURL+"/enterprise/updateworkInfo",
            method: "post",
            params:{
              info: this.work_from.info,
              tid:this.tid,
              uid:this.workinfo.enterInfo.uid,
              type:"info"
            }
          }).then(res => {
            if(res.status){
              this.$message.success(res.data.msg);
            }else {
              this.$message.error(res.data.msg);
            }
            setTimeout(() => {
              this.gs_state = false;
              this.gs_input_state = false;
              this.enterinfo();
            }, 1500);
          })
          break;
        }
      },
    delete_emp(){
      this.$axios({
        url: this.$axios.defaults.baseURL+"/enterprise/deletework",
        method: "get",
        params:{
          wid : this.wid,
          tid : this.tid
        }
      }).then(res => {
        if(res.data.status){
          this.$message.success(res.data.msg);
          this.$router.replace("/enterhome");
        }else{
          this.$message.error(res.data.msg);
        }
      })
    },
    enterinfo(){
        this.$axios({
          url: this.$axios.defaults.baseURL+"/student/maininfo",
          method: "get",
          params:{
            wid : this.wid,
            tid : this.tid
          }
        }).then(res => {
          this.workinfo = res.data;
          this.flag = res.data.staclloct;
          this.log = res.data.address.location.split(",")[0];
          this.loh = res.data.address.location.split(",")[1];
          this.url = res.data.enterInfo.logoimg;
        })
    },
  },
  mounted() {
    this.enterinfo();

  }
}
</script>

<style scoped>

.el-header, .el-footer {
  background-color: #B3C0D1;
  color: #333;
  line-height: 60px;
}
.amap-wrapper {
  width: 800px;
  height: 200px;
}
.el-aside {
  color: #333;
  font-family: Arial;
  border-radius: 5px 5px 5px 5px;
  width: 20%;
  background-color: white;
}

.el-main {
  background-color: white;
  color: #333;
  margin-left: 10px;
  border-radius: 5px 5px 5px 5px;
}
.srca{
  margin-top: 10px;
  margin-left: 10px;
}

body > .el-container {
  margin-bottom: 40px;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}

li{
  margin-top: 8px;
  list-style: none;
}
</style>
